import React from "react";

class Header extends React.Component{
  constructor(props){
    super(props)
    this.state  = {
      title:""
    }
  }

  componentWillMount(){
    console.log("componentWillMount")
    // 更改组件的默认状态
    this.setState({
      title:this.props.title
    })
  }
  //组件的state改变 render就会被调用 
  render() {
    console.log("render")
    return (
      <div>
        {this.state.title}
      </div>
    );
  }
  //mounted
  componentDidMount(){
    console.log("componentDidMount")
  }


  //更新阶段
  componentWillReceiveProps(props){
    console.log(this.props);
    this.props = props;
    this.setState({
      title:this.props.title
    })
  }

  shouldComponentUpdate(){
    return true;
  }

  componentWillUpdate(){

  }

  //执行render函数

  componentDidUpdate(){

  }

  componentWillUnmount(){
    
  }

}

export default Header;